package com.aspose.cells;

import java.util.ArrayList;

class ztr {
   private PivotTable a;
   private String b;

   ztr(PivotTable var1, String var2) {
      this.a = var1;
      this.b = var2;
   }

   void a(zcfx var1) throws Exception {
      var1.b(true);
      var1.b("pivotTableDefinition");
      var1.a("xmlns", zase.c);
      this.t(var1);
      this.r(var1);
      this.p(var1);
      this.g(var1);
      this.i(var1);
      this.h(var1);
      this.j(var1);
      this.f(var1);
      this.e(var1);
      this.n(var1);
      this.d(var1);
      this.m(var1);
      this.o(var1);
      this.b(var1);
      this.c(var1);
      this.k(var1);
      this.q(var1);
      var1.b();
      var1.d();
      var1.e();
   }

   private void b(zcfx var1) throws Exception {
      int var2 = this.a.V;
      if (var2 != 0) {
         var1.b("rowHierarchiesUsage");
         var1.a("count", zase.y(var2));
         var1.d(this.a.W);
         var1.b();
      }
   }

   private void c(zcfx var1) throws Exception {
      int var2 = this.a.U;
      if (var2 != 0) {
         var1.b("colHierarchiesUsage");
         var1.a("count", zase.y(var2));
         var1.d(this.a.X);
         var1.b();
      }
   }

   private void d(zcfx var1) throws Exception {
      int var2 = this.a.T;
      if (var2 != 0) {
         var1.b("pivotHierarchies");
         var1.a("count", zase.y(var2));
         var1.d(this.a.S);
         var1.b();
      }
   }

   private void e(zcfx var1) throws Exception {
      PivotFieldCollection var2 = this.a.getDataFields();
      int var3 = var2.getCount();
      if (var3 != 0) {
         var1.b("dataFields");
         var1.a("count", zase.y(var3));

         for(int var4 = 0; var4 < var3; ++var4) {
            PivotField var5 = var2.get(var4);
            zbqn var6 = var5.i;
            var1.b("dataField");
            if (var6.b() != null) {
               var1.a("name", var6.b());
            }

            var1.a("fld", zase.y(var6.h.getBaseIndex()));
            if (var6.a != 0) {
               var1.a("subtotal", zase.ab(var6.a));
            }

            if (var6.b != 0 && var6.b != 10 && var6.b != 9 && var6.b != 11 && var6.b != 14 && var6.b != 13 && var6.b != 12) {
               var1.a("showDataAs", zase.ac(var6.b));
            }

            var1.a("baseField", zase.y(var6.c));
            if (var5.getBaseItemPosition() == 0) {
               var1.a("baseItem", zase.y(1048828));
            } else if (var5.getBaseItemPosition() == 1) {
               var1.a("baseItem", zase.y(1048829));
            } else {
               var1.a("baseItem", zase.y(var6.d));
            }

            if (var6.e > 0) {
               var1.a("numFmtId", zase.a(var6.e));
            }

            this.d(var1, var5);
            var1.b();
         }

         var1.b();
      }
   }

   private void f(zcfx var1) throws Exception {
      PivotFieldCollection var2 = this.a.getPageFields();
      int var3 = var2.getCount();
      if (var3 != 0) {
         var1.b("pageFields");
         var1.a("count", zase.y(var3));

         for(int var4 = 0; var4 < var3; ++var4) {
            PivotField var5 = var2.get(var4);
            var1.b("pageField");
            var1.a("fld", zase.y(var5.t));
            if (var5.j.b != 32765 && !var5.isMultipleItemSelectionAllowed()) {
               var1.a("item", zase.a(var5.j.b));
            }

            var1.a("hier", zase.y(var5.j.d));
            if (var5.j.e != null) {
               var1.a("name", var5.j.e);
            }

            if (var5.j.f != null) {
               var1.a("cap", var5.j.f);
            }

            var1.b();
         }

         var1.b();
      }
   }

   private void g(zcfx var1) throws Exception {
      PivotFieldCollection var2 = this.a.getRowFields();
      int var3 = var2.getCount();
      if (var3 != 0) {
         var1.b("rowFields");
         var1.a("count", zase.y(var3));

         for(int var4 = 0; var4 < var3; ++var4) {
            PivotField var5 = var2.get(var4);
            var1.b("field");
            var1.a("x", zase.a((short)var5.t));
            var1.b();
         }

         var1.b();
      }
   }

   private void h(zcfx var1) throws Exception {
      PivotFieldCollection var2 = this.a.getColumnFields();
      int var3 = var2.getCount();
      if (var3 != 0) {
         var1.b("colFields");
         var1.a("count", zase.y(var3));

         for(int var4 = 0; var4 < var3; ++var4) {
            PivotField var5 = var2.get(var4);
            var1.b("field");
            var1.a("x", zase.a((short)var5.t));
            var1.b();
         }

         var1.b();
      }
   }

   private void i(zcfx var1) throws Exception {
      ArrayList var2 = this.a.g;
      if (var2 != null) {
         int var3 = var2.size();
         if (var3 == 0) {
            if (this.a.getRowFields().getCount() == 0) {
               var1.b("rowItems");
               var1.a("count", zase.y(1));
               var1.b("i");
               var1.b();
               var1.b();
            }

         } else {
            var1.b("rowItems");
            var1.a("count", zase.y(var3));

            for(int var4 = 0; var4 < var3; ++var4) {
               int[] var5 = (int[])((int[])var2.get(var4));
               this.a(var1, var5);
            }

            var1.b();
         }
      }
   }

   private void a(zcfx var1, int[] var2) throws Exception {
      var1.b("i");
      if (var2[1] != 0) {
         var1.a("t", zase.aJ(var2[1]));
      }

      int var3 = (var2[3] & 510) >> 1;
      if (var3 != 0) {
         var1.a("i", zase.y(var3));
      }

      if (var2[0] != 0) {
         var1.a("r", zase.y(var2[0]));
      }

      if (var2[2] > 0) {
         for(int var4 = var2[0]; var4 < var2[2]; ++var4) {
            var1.b("x");
            if (var2[4 + var4] != 0) {
               var1.a("v", zase.y(var2[4 + var4]));
            }

            var1.b();
         }
      }

      var1.b();
   }

   private void j(zcfx var1) throws Exception {
      ArrayList var2 = this.a.h;
      if (var2 != null) {
         int var3 = var2.size();
         if (var3 == 0) {
            if (this.a.getColumnFields().getCount() == 0) {
               var1.b("colItems");
               var1.a("count", zase.y(1));
               var1.b("i");
               var1.b();
               var1.b();
            }

         } else {
            var1.b("colItems");
            var1.a("count", zase.y(var3));

            for(int var4 = 0; var4 < var3; ++var4) {
               int[] var5 = (int[])((int[])var2.get(var4));
               this.a(var1, var5);
            }

            var1.b();
         }
      }
   }

   private void k(zcfx var1) throws Exception {
      PivotFilterCollection var2 = this.a.ai;
      if (var2 != null) {
         int var3 = var2.getCount();
         if (var3 != 0) {
            var1.b("filters");
            var1.a("count", zase.y(var3));

            for(int var4 = 0; var4 < var3; ++var4) {
               PivotFilter var5 = var2.get(var4);
               var1.b("filter");
               var1.a("fld", zase.y(var5.a));
               var1.a("type", zavb.f(var5.b));
               var1.a("evalOrder", zase.y(var5.e));
               var1.a("id", zase.y(var5.c));
               var1.a("iMeasureFld", zase.y(var5.d));
               if (var5.j != null) {
                  var1.a("name", var5.j);
               }

               if (var5.getValue1() != null) {
                  var1.a("stringValue1", var5.getValue1());
               }

               if (var5.getValue2() != null) {
                  var1.a("stringValue2", var5.getValue2());
               }

               if (var5.i != -1) {
                  var1.a("mpFld", zase.y(var5.i));
               }

               zuf.a(var1, var5.f, true);
               var1.b();
            }

            var1.b();
         }
      }
   }

   private void a(zcfx var1, zbro var2) throws Exception {
      var1.b("pivotArea");
      if (var2.h()) {
         var1.a("outline", "1");
      } else {
         var1.a("outline", "0");
      }

      var1.a("fieldPosition", zase.a(var2.a));
      if (var2.f() == 2) {
         var1.a("axis", "axisCol");
      } else if (var2.f() == 4) {
         var1.a("axis", "axisPage");
      } else if (var2.f() == 1) {
         var1.a("axis", "axisRow");
      } else if (var2.f() == 8) {
         var1.a("axis", "axisValues");
      }

      if (var2.j) {
         var1.a("collapsedLevelsAreSubtotals", "1");
      }

      if (!var2.a()) {
         var1.a("dataOnly", "0");
      }

      if ((var2.b & 255) != 255) {
         if ((var2.b & 255) == 254) {
            var1.a("field", "-2");
         } else {
            var1.a("field", zase.a(var2.b));
         }
      }

      if (var2.d()) {
         var1.a("grandCol", "1");
      }

      if (var2.c()) {
         var1.a("grandRow", "1");
      }

      if (var2.b()) {
         var1.a("labelOnly", "1");
      }

      if (var2.j()) {
         CellArea var3 = new CellArea();
         var3.StartRow = var2.f & 255;
         var3.EndRow = var2.g & 255;
         var3.StartColumn = var2.h & 255;
         var3.EndColumn = var2.i & 255;
         var1.a("offset", zase.a(var3));
      }

      switch(var2.g()) {
      case 0:
         var1.a("type", "none");
         break;
      case 1:
         var1.a("type", "normal");
         break;
      case 2:
         var1.a("type", "data");
         break;
      case 3:
         var1.a("type", "all");
         break;
      case 4:
         var1.a("type", "origin");
         break;
      case 5:
         var1.a("type", "button");
         break;
      case 6:
         var1.a("type", "topRight");
      }

      if (var2.e.size() > 0) {
         int var8 = var2.e.size();
         var1.b("references");
         var1.a("count", zase.y(var8));

         for(int var4 = 0; var4 < var2.e.size(); ++var4) {
            zbqw var5 = (zbqw)var2.e.get(var4);
            var1.b("reference");
            var1.a("field", zase.a((long)((short)(var5.b() & '\uffff')) & 4294967295L & 4294967295L));
            if (var5.h) {
               var1.a("avgSubtotal", "1");
            }

            if (var5.g) {
               var1.a("countASubtotal", "1");
            }

            if (var5.l) {
               var1.a("countSubtotal", "1");
            }

            if (var5.e) {
               var1.a("defaultSubtotal", "1");
            }

            if (var5.i) {
               var1.a("maxSubtotal", "1");
            }

            if (var5.j) {
               var1.a("minSubtotal", "1");
            }

            if (var5.k) {
               var1.a("productSubtotal", "1");
            }

            if (var5.n) {
               var1.a("stdDevPSubtotal", "1");
            }

            if (var5.m) {
               var1.a("stdDevSubtotal", "1");
            }

            if (var5.f) {
               var1.a("sumSubtotal", "1");
            }

            if (var5.p) {
               var1.a("varPSubtotal", "1");
            }

            if (var5.o) {
               var1.a("varSubtotal", "1");
            }

            if (!var5.c()) {
               var1.a("selected", "0");
            }

            int var6 = var5.c.size();
            var1.a("count", zase.y(var6));

            for(int var7 = 0; var7 < var6; ++var7) {
               var1.b("x");
               var1.a("v", zase.y((Integer)var5.c.get(var7)));
               var1.b();
            }

            var1.b();
         }

         var1.b();
      }

      var1.b();
   }

   private int a() {
      int var1 = 1;
      Worksheet var2 = this.a.a.b;
      if (var2 != null) {
         int var3;
         int var5;
         for(var3 = 0; var3 < this.a.a.b.getConditionalFormattings().getCount(); ++var3) {
            FormatConditionCollection var4 = var2.getConditionalFormattings().get(var3);

            for(var5 = 0; var5 < var4.getCount(); ++var5) {
               ++var1;
            }
         }

         if (var2.b != null) {
            for(var3 = 0; var3 < var2.b.getCount(); ++var3) {
               PivotTable var6 = var2.b.get(var3);
               if (var6.aj != null) {
                  for(var5 = 0; var5 < var6.aj.getCount(); ++var5) {
                     ++var1;
                  }
               }
            }

            --var1;
         }
      }

      return var1;
   }

   private void l(zcfx var1) throws Exception {
      PivotFormatConditionCollection var2 = this.a.aj;
      if (var2 != null && var2.getCount() != 0) {
         int var3 = this.a();
         int var4 = var2.getCount();
         int var5 = zavb.a(var2);
         if (var5 >= 1) {
            var1.b("x14:conditionalFormats");
            var1.a("count", zase.y(var5));

            for(int var6 = 0; var6 < var4; ++var6) {
               PivotFormatCondition var7 = var2.get(var6);
               FormatConditionCollection var8 = var7.a();
               if (var8 != null && var8.a(true)) {
                  var1.b("x14:conditionalFormat");
                  if (var7.c == 0) {
                     var1.a("priority", zase.y(var3));
                  } else {
                     var1.a("priority", zase.y(var7.c));
                  }

                  --var3;
                  if (var7.d != 2) {
                     var1.a("scope", zavb.a(var7.d));
                  }

                  if (var7.e != 0) {
                     var1.a("type", zavb.b(var7.e));
                  }

                  if (var8.getCount() > 0) {
                     var1.a("id", "{" + com.aspose.cells.b.a.zr.a(var8.get(0).b()) + "}");
                  }

                  int var9 = var7.b.size();
                  var1.b("x14:pivotAreas");
                  var1.a("count", zase.y(var9));

                  for(int var10 = 0; var10 < var9; ++var10) {
                     zbro var11 = (zbro)var7.b.get(var10);
                     this.a(var1, var11);
                  }

                  var1.b();
                  var1.b();
               }
            }

            var1.b();
         }
      }
   }

   private void m(zcfx var1) throws Exception {
      PivotFormatConditionCollection var2 = this.a.aj;
      if (var2 != null && var2.getCount() != 0) {
         int var3 = this.a();
         int var4 = zavb.a(var2);
         int var5 = var2.getCount();
         int var6 = var5 - var4;
         if (var6 >= 1) {
            var1.b("conditionalFormats");
            var1.a("count", zase.y(var6));

            for(int var7 = 0; var7 < var5; ++var7) {
               PivotFormatCondition var8 = var2.get(var7);
               FormatConditionCollection var9 = var8.a();
               if (var9 != null && !var9.a(false)) {
                  var1.b("conditionalFormat");
                  if (var8.c == 0) {
                     var1.a("priority", zase.y(var3));
                  } else {
                     var1.a("priority", zase.y(var8.c));
                  }

                  --var3;
                  if (var8.d != 2) {
                     var1.a("scope", zavb.a(var8.d));
                  }

                  if (var8.e != 0) {
                     var1.a("type", zavb.b(var8.e));
                  }

                  int var10 = var8.b.size();
                  var1.b("pivotAreas");
                  var1.a("count", zase.y(var10));

                  for(int var11 = 0; var11 < var10; ++var11) {
                     zbro var12 = (zbro)var8.b.get(var11);
                     this.a(var1, var12);
                  }

                  var1.b();
                  var1.b();
               }
            }

            var1.b();
         }
      }
   }

   private void n(zcfx var1) throws Exception {
      zbqz var2 = this.a.ag;
      int var3 = var2.getCount();
      if (var3 != 0) {
         var1.b("formats");
         var1.a("count", zase.y(var3));

         for(int var4 = 0; var4 < var2.getCount(); ++var4) {
            zbqy var5 = var2.a(var4);
            var1.b("format");
            if (var5.a == 0) {
               var1.a("action", "blank");
            }

            if (var5.b != -1) {
               var1.a("dxfId", zase.y(var5.b));
            }

            zbro var6 = var5.c;
            var1.b("pivotArea");
            if (var6.h()) {
               var1.a("outline", "1");
            } else {
               var1.a("outline", "0");
            }

            var1.a("fieldPosition", zase.a(var6.a));
            if (var6.f() == 2) {
               var1.a("axis", "axisCol");
            } else if (var6.f() == 4) {
               var1.a("axis", "axisPage");
            } else if (var6.f() == 1) {
               var1.a("axis", "axisRow");
            } else if (var6.f() == 8) {
               var1.a("axis", "axisValues");
            }

            if (var6.j) {
               var1.a("collapsedLevelsAreSubtotals", "1");
            }

            if (!var6.a()) {
               var1.a("dataOnly", "0");
            }

            if ((var6.b & 255) != 255) {
               if ((var6.b & 255) == 254) {
                  var1.a("field", "-2");
               } else {
                  var1.a("field", zase.a(var6.b));
               }
            }

            if (var6.d()) {
               var1.a("grandCol", "1");
            }

            if (var6.c()) {
               var1.a("grandRow", "1");
            }

            if (var6.b()) {
               var1.a("labelOnly", "1");
            }

            if (var6.j()) {
               CellArea var7 = new CellArea();
               var7.StartRow = var6.f & 255;
               var7.EndRow = var6.g & 255;
               var7.StartColumn = var6.h & 255;
               var7.EndColumn = var6.i & 255;
               var1.a("offset", zase.a(var7));
            }

            switch(var6.g()) {
            case 3:
               var1.a("type", "all");
               break;
            case 4:
               var1.a("type", "origin");
               break;
            case 5:
               var1.a("type", "button");
               break;
            case 6:
               var1.a("type", "topRight");
            }

            if (var6.e.size() > 0) {
               int var12 = var6.e.size();
               var1.b("references");
               var1.a("count", zase.y(var12));
               int var8 = 0;

               while(true) {
                  if (var8 >= var6.e.size()) {
                     var1.b();
                     break;
                  }

                  zbqw var9 = (zbqw)var6.e.get(var8);
                  var1.b("reference");
                  var1.a("field", zase.a((long)((short)(var9.b() & '\uffff')) & 4294967295L & 4294967295L));
                  if (var9.h) {
                     var1.a("avgSubtotal", "1");
                  }

                  if (var9.g) {
                     var1.a("countASubtotal", "1");
                  }

                  if (var9.l) {
                     var1.a("countSubtotal", "1");
                  }

                  if (var9.e) {
                     var1.a("defaultSubtotal", "1");
                  }

                  if (var9.i) {
                     var1.a("maxSubtotal", "1");
                  }

                  if (var9.j) {
                     var1.a("minSubtotal", "1");
                  }

                  if (var9.k) {
                     var1.a("productSubtotal", "1");
                  }

                  if (var9.n) {
                     var1.a("stdDevPSubtotal", "1");
                  }

                  if (var9.m) {
                     var1.a("stdDevSubtotal", "1");
                  }

                  if (var9.f) {
                     var1.a("sumSubtotal", "1");
                  }

                  if (var9.p) {
                     var1.a("varPSubtotal", "1");
                  }

                  if (var9.o) {
                     var1.a("varSubtotal", "1");
                  }

                  if (!var9.c()) {
                     var1.a("selected", "0");
                  }

                  int var10 = var9.c.size();
                  var1.a("count", zase.y(var10));

                  for(int var11 = 0; var11 < var10; ++var11) {
                     var1.b("x");
                     if ((Integer)var9.c.get(var11) == 32767) {
                        var1.a("v", zase.y(1048832));
                     } else {
                        var1.a("v", zase.y((Integer)var9.c.get(var11)));
                     }

                     var1.b();
                  }

                  var1.b();
                  ++var8;
               }
            }

            var1.b();
            var1.b();
         }

         var1.b();
      }
   }

   private void o(zcfx var1) throws Exception {
      var1.b("pivotTableStyleInfo");
      if (this.a.getPivotTableStyleName() != null && this.a.getPivotTableStyleName().length() != 0) {
         var1.a("name", this.a.getPivotTableStyleName());
      }

      var1.a("showRowHeaders", this.a.getShowPivotStyleRowHeader() ? "1" : "0");
      var1.a("showColHeaders", this.a.getShowPivotStyleColumnHeader() ? "1" : "0");
      var1.a("showRowStripes", this.a.getShowPivotStyleRowStripes() ? "1" : "0");
      var1.a("showColStripes", this.a.getShowPivotStyleColumnStripes() ? "1" : "0");
      var1.a("showLastColumn", this.a.getShowPivotStyleLastColumn() ? "1" : "0");
      var1.b();
   }

   private int a(PivotField var1) {
      int var2 = var1.d.getCount();
      if (var1.isAutoSubtotals()) {
         ++var2;
      } else if (!var1.getSubtotals(0)) {
         int var3 = var1.b.a;

         for(int var4 = 1; var4 < 14; ++var4) {
            if (((var3 & '\uffff') >> var4 & 1) != 0) {
               ++var2;
            }
         }
      }

      return var2;
   }

   private void a(zcfx var1, PivotField var2) throws Exception {
      if (var2.getSubtotals(0)) {
         var1.a("defaultSubtotal", "0");
      }

      if (var2.getSubtotals(2)) {
         var1.a("sumSubtotal", "1");
      }

      if (var2.getSubtotals(4)) {
         var1.a("countSubtotal", "1");
      }

      if (var2.getSubtotals(128)) {
         var1.a("countASubtotal", "1");
      }

      if (var2.getSubtotals(256)) {
         var1.a("stdDevSubtotal", "1");
      }

      if (var2.getSubtotals(512)) {
         var1.a("stdDevPSubtotal", "1");
      }

      if (var2.getSubtotals(1024)) {
         var1.a("varSubtotal", "1");
      }

      if (var2.getSubtotals(2048)) {
         var1.a("varPSubtotal", "1");
      }

      if (var2.getSubtotals(8)) {
         var1.a("avgSubtotal", "1");
      }

      if (var2.getSubtotals(16)) {
         var1.a("maxSubtotal", "1");
      }

      if (var2.getSubtotals(32)) {
         var1.a("minSubtotal", "1");
      }

      if (var2.getSubtotals(64)) {
         var1.a("productSubtotal", "1");
      }

   }

   private boolean b() {
      return this.a.getAutoFormatType() == 12 || this.a.getAutoFormatType() == 13 || this.a.getAutoFormatType() == 14 || this.a.getAutoFormatType() == 15 || this.a.getAutoFormatType() == 16 || this.a.getAutoFormatType() == 18;
   }

   private void a(zcfx var1, PivotField var2, int var3) throws Exception {
      if (var2.m != 0) {
         var1.a("axis", zase.Z(var2.m));
      }

      if (var2.h()) {
         var1.a("dataField", "1");
      }

      if (var2.getShowInOutlineForm()) {
         if (!var2.getShowCompact()) {
            var1.a("compact", "0");
         }

         if (!var2.getShowSubtotalAtTop()) {
            var1.a("subtotalTop", "0");
         }
      } else {
         if (!var2.getShowCompact()) {
            var1.a("compact", "0");
         }

         var1.a("outline", "0");
         if (!var2.getShowSubtotalAtTop()) {
            var1.a("subtotalTop", "0");
         }
      }

      if (var2.o) {
         var1.a("allDrilled", "1");
      }

      if (!var2.getShowAllItems()) {
         var1.a("showAll", "0");
      }

      if (var2.isAutoShow()) {
         var1.a("autoShow", "1");
         if (!var2.isAscendShow()) {
            var1.a("topAutoShow", "0");
         }
      }

      if (var3 == 0) {
         if (this.b() || var2.getInsertBlankRow()) {
            var1.a("insertBlankRow", "1");
         }
      } else if (var2.getInsertBlankRow()) {
         var1.a("insertBlankRow", "1");
      }

      if (var2.isIncludeNewItemsInFilter()) {
         var1.a("includeNewItemsInFilter", "1");
      }

      if (var2.isAutoShow()) {
         short var4 = (short)var2.getAutoShowCount();
         if (var4 != 10) {
            var1.a("itemPageCount", zase.a(var4));
         }
      }

      if (var2.n) {
         var1.a("multipleItemSelectionAllowed", "1");
      }

      if (var2.isAutoSort()) {
         String var5 = var2.isAscendSort() ? "ascending" : "descending";
         var1.a("sortType", var5);
      }

      if (var2.getAutoShowField() >= 0) {
         var1.a("rankBy", zase.y(var2.getAutoShowField()));
      }

      if (var2.c.d > 0) {
         var1.a("numFmtId", zase.a(var2.c.d));
      }

      if (var2.getDisplayName() != null) {
         var1.a("name", var2.getDisplayName());
      }

      if (var2.isInsertPageBreaksBetweenItems()) {
         var1.a("insertPageBreak", "1");
      }

      if (!var2.getDragToRow()) {
         var1.a("dragToRow", "0");
      }

      if (!var2.getDragToColumn()) {
         var1.a("dragToCol", "0");
      }

      if (!var2.getDragToPage()) {
         var1.a("dragToPage", "0");
      }

      if (!var2.getDragToData()) {
         var1.a("dragToData", "0");
      }

      if (!var2.getDragToHide()) {
         var1.a("dragOff", "0");
      }

      if (var2.p) {
         var1.a("dataSourceSort", "1");
      }

      this.a(var1, var2);
   }

   private void b(zcfx var1, PivotField var2) throws Exception {
      var1.b("autoSortScope");
      this.a(var1, var2.e);
      var1.b();
   }

   private void c(zcfx var1, PivotField var2) throws Exception {
      PivotItemCollection var3 = var2.d;
      if (var3 != null && var3.getCount() != 0) {
         var1.b("items");
         int var4 = this.a(var2);
         boolean var5 = false;
         var1.a("count", zase.y(var4));
         int var10;
         if (var2.isAutoSubtotals()) {
            var10 = var4 - 1;
         } else {
            var10 = var4;
         }

         var10 = Math.min(var10, var3.getCount());

         int var6;
         for(var6 = 0; var6 < var10; ++var6) {
            PivotItem var7 = var3.get(var6);
            if (var7.getIndex() != -1) {
               var1.b("item");
               if (var7.d != null && var7.d.length() > 0) {
                  var1.a("n", var7.d);
               }

               if (var7.isHidden()) {
                  var1.a("h", "1");
               }

               if (var7.a()) {
                  var1.a("sd", "0");
               }

               if (var7.b()) {
                  var1.a("f", "1");
               }

               if (var7.c()) {
                  var1.a("m", "1");
               }

               if (var7.h) {
                  var1.a("s", "1");
               }

               if (var7.f) {
                  var1.a("c", "1");
               }

               var1.a("x", zase.y(var7.getIndex()));
               if (var7.g) {
                  var1.a("d", "1");
               }

               var1.b();
            }
         }

         if (var2.isAutoSubtotals()) {
            this.a(var1, "t", "default");
         } else if (!var2.getSubtotals(0)) {
            var6 = var2.b.a;

            for(int var11 = 1; var11 < 14; ++var11) {
               if (((var6 & '\uffff') >> var11 & 1) != 0) {
                  int var8 = 1 << var11;
                  String var9 = zase.aa(var8);
                  this.a(var1, "t", var9);
               }
            }
         }

         var1.b();
      }
   }

   private void p(zcfx var1) throws Exception {
      PivotFieldCollection var2 = this.a.getBaseFields();
      int var3 = var2.getCount();
      if (var3 != 0) {
         var1.b("pivotFields");
         var1.a("count", zase.y(var3));

         for(int var4 = 0; var4 < var3; ++var4) {
            PivotField var5 = var2.get(var4);
            var1.b("pivotField");
            this.a(var1, var5, var4);
            this.c(var1, var5);
            if (var5.isAutoSort() && var5.getAutoSortField() >= 0 && var5.e != null) {
               this.b(var1, var5);
            }

            if (var5.isRepeatItemLabels()) {
               this.e(var1, var5);
            }

            var1.b();
         }

         var1.b();
      }
   }

   private void q(zcfx var1) throws Exception {
      int var2 = 0;
      PivotFormatConditionCollection var3 = this.a.aj;
      if (var3 != null && var3.getCount() != 0) {
         var2 = zavb.a(this.a.aj);
      }

      if (this.a.J || this.a.getEnableDataValueEditing() || this.a.P != null || this.a.Q != null || var2 > 0) {
         var1.b("extLst");
         var1.b("ext");
         var1.a("uri", this.a.R);
         var1.a("xmlns:x14", zase.f);
         var1.b("x14:pivotTableDefinition");
         if (this.a.J) {
            var1.a("hideValuesRow", "1");
         }

         if (this.a.getEnableDataValueEditing()) {
            var1.a("enableEdit", "1");
         }

         if (this.a.P != null) {
            var1.a("altText", this.a.P);
         }

         if (this.a.Q != null) {
            var1.a("altTextSummary", this.a.Q);
         }

         if (var2 > 0) {
            var1.a("xmlns:xm", "http://schemas.microsoft.com/office/excel/2006/main");
            this.l(var1);
         }

         var1.b();
         var1.b();
         var1.b();
      }

   }

   private void d(zcfx var1, PivotField var2) throws Exception {
      boolean var3 = false;
      switch(var2.i.b) {
      case 9:
      case 10:
      case 11:
      case 12:
      case 13:
      case 14:
         var3 = true;
      }

      boolean var4 = var3 || var2.getFunction() == 11;
      if (var4) {
         var1.b("extLst");
         if (var3) {
            var1.b("ext");
            var1.a("uri", "{E15A36E0-9728-4e99-A89B-3F7291B0FE68}");
            var1.a("xmlns:x14", zase.f);
            var1.b("x14:dataField");
            var1.a("pivotShowAs", zase.ac(var2.i.b));
            var1.b();
            var1.b();
         }

         if (var2.getFunction() == 11) {
            var1.b("ext");
            var1.a("uri", "{FABC7310-3BB5-11E1-824E-6D434824019B}");
            var1.a("xmlns:x15", zase.g);
            var1.b("x15:dataField");
            var1.a("isCountDistinct", "1");
            var1.b();
            var1.b();
         }

         var1.b();
      }
   }

   private void e(zcfx var1, PivotField var2) throws Exception {
      var1.b("extLst");
      var1.b("ext");
      var1.a("uri", var2.s);
      var1.a("xmlns:x14", zase.f);
      var1.b("x14:pivotField");
      var1.a("fillDownLabels", "1");
      var1.b();
      var1.b();
      var1.b();
   }

   private void a(zcfx var1, String var2, String var3) throws Exception {
      var1.b("item");
      var1.a(var2, var3);
      var1.b();
   }

   private void r(zcfx var1) throws Exception {
      var1.b("location");
      var1.a("ref", zase.a(this.a.getTableRange1()));
      int var2 = this.a.m - this.a.i > 0 ? this.a.m - this.a.i : 0;
      int var3 = this.a.n - this.a.i > 0 ? this.a.n - this.a.i : 0;
      int var4 = this.a.o - this.a.k > 0 ? this.a.o - this.a.k : 1;
      var1.a("firstHeaderRow", zase.y(var2));
      var1.a("firstDataRow", zase.y(var3));
      var1.a("firstDataCol", zase.y(var4));
      if (this.a.getPageFields().getCount() > 0) {
         if (this.a.p != -1 && this.a.q != -1) {
            var1.a("rowPageCount", zase.y(this.a.p));
            var1.a("colPageCount", zase.y(this.a.q));
         } else {
            var1.a("rowPageCount", zase.y(this.a.getPageFields().getCount()));
            var1.a("colPageCount", "1");
         }
      }

      var1.b();
   }

   private void s(zcfx var1) throws Exception {
      boolean var2 = false;
      int var3 = -1;
      if (this.a.b.c.getCount() > 1) {
         PivotField var4 = this.a.getDataField();
         if (var4 != null) {
            var3 = var4.getPosition();
            switch(var4.m) {
            case 1:
               var2 = true;
               if (var3 == this.a.getRowFields().getCount() - 1) {
                  var3 = -1;
               }
               break;
            case 2:
               if (var3 == this.a.getColumnFields().getCount() - 1) {
                  var3 = -1;
               }
            }
         }
      }

      if (var2) {
         var1.a("dataOnRows", "1");
      }

      if (var3 != -1) {
         var1.a("dataPosition", zase.y(var3));
      }

   }

   private void t(zcfx var1) throws Exception {
      var1.a("name", this.a.getName());
      var1.a("cacheId", this.b);
      this.s(var1);
      String var2 = "0";
      if (this.a.getAutoFormatType() != 1) {
         int var3 = zase.X(this.a.getAutoFormatType());
         var1.a("autoFormatId", zase.y(var3));
         var2 = "1";
      }

      var1.a("applyNumberFormats", var2);
      var1.a("applyBorderFormats", var2);
      var1.a("applyFontFormats", var2);
      var1.a("applyPatternFormats", var2);
      var1.a("applyAlignmentFormats", var2);
      var1.a("applyWidthHeightFormats", "1");
      var1.a("dataCaption", this.a.b.h);
      if (!"".equals(this.a.getErrorString())) {
         var1.a("errorCaption", this.a.getErrorString());
      }

      if (this.a.e != null && this.a.e.b != null) {
         var1.a("grandTotalCaption", this.a.getGrandTotalName());
      }

      if (this.a.getDisplayErrorString()) {
         var1.a("showError", "1");
      }

      if (!"".equals(this.a.getNullString())) {
         var1.a("missingCaption", this.a.getNullString());
      }

      if (this.a.getDisplayNullString()) {
         var1.a("showMissing", "1");
      } else {
         var1.a("showMissing", "0");
      }

      if (!this.a.getDisplayImmediateItems()) {
         var1.a("showItems", "0");
      }

      if (!this.a.D) {
         var1.a("showHeaders", "0");
      }

      if (!this.a.E) {
         var1.a("customListSort", "0");
      }

      if (!this.a.getEnableDrilldown()) {
         var1.a("enableDrill", "0");
      }

      if (!this.a.getShowDrill()) {
         var1.a("showDrill", "0");
      }

      if (this.a.getPreserveFormatting()) {
         var1.a("preserveFormatting", "1");
      } else {
         var1.a("preserveFormatting", "0");
      }

      if (this.a.isAutoFormat()) {
         var1.a("useAutoFormatting", "1");
      }

      if (this.a.getPageFieldWrapCount() > 0) {
         var1.a("pageWrap", zase.y(this.a.getPageFieldWrapCount()));
      }

      if (this.a.getPageFieldOrder() == 1) {
         var1.a("pageOverThenDown", "1");
      }

      if (this.a.getSubtotalHiddenPageItems()) {
         var1.a("subtotalHiddenItems", "1");
      }

      if (!this.a.getColumnGrand()) {
         var1.a("rowGrandTotals", "0");
      }

      if (!this.a.getRowGrand()) {
         var1.a("colGrandTotals", "0");
      }

      if (!this.a.getEnableFieldList()) {
         var1.a("disableFieldList", "1");
      }

      if (!this.a.getEnableWizard()) {
         var1.a("EnableWizard", "0");
      }

      if (!this.a.getEnableFieldDialog()) {
         var1.a("enableFieldProperties", "0");
      }

      if (this.a.getPrintTitles()) {
         var1.a("fieldPrintTitles", "1");
      }

      if (this.a.getItemPrintTitles()) {
         var1.a("itemPrintTitles", "1");
      }

      if (!this.a.u) {
         var1.a("compact", "0");
      }

      if (!this.a.v) {
         var1.a("compactData", "0");
      }

      if (this.a.w) {
         var1.a("outline", "1");
      }

      if (this.a.x) {
         var1.a("outlineData", "1");
      }

      if (this.a.getMergeLabels()) {
         var1.a("mergeItem", "1");
      }

      if (this.a.A) {
         var1.a("createdVersion", zase.y(this.a.B));
      } else {
         var1.a("createdVersion", zase.y(4));
      }

      if (this.a.y) {
         var1.a("updatedVersion", zase.y(this.a.z));
      }

      if (this.a.C != -1) {
         var1.a("indent", zase.y(this.a.C));
      }

      if (this.a.t) {
         var1.a("gridDropZones", "1");
      }

      if (this.a.getRowHeaderCaption() != null) {
         var1.a("rowHeaderCaption", this.a.getRowHeaderCaption());
      }

      if (this.a.getColumnHeaderCaption() != null) {
         var1.a("colHeaderCaption", this.a.getColumnHeaderCaption());
      }

      if (this.a.getTag() != null) {
         var1.a("tag", this.a.getTag());
      }

      if (!this.a.isMultipleFieldFilters()) {
         var1.a("multipleFieldFilters", "0");
      }

      if (!this.a.getShowDataTips()) {
         var1.a("showDataTips", "0");
      }

      if (this.a.getShowMemberPropertyTips()) {
         var1.a("showMemberPropertyTips", "1");
      } else {
         var1.a("showMemberPropertyTips", "0");
      }

      if (this.a.getShowEmptyCol()) {
         var1.a("showEmptyCol", "1");
      }

      if (this.a.getShowEmptyRow()) {
         var1.a("showEmptyRow", "1");
      }

      if (this.a.getFieldListSortAscending()) {
         var1.a("fieldListSortAscending", "1");
      }

      if (this.a.getPrintDrill()) {
         var1.a("printDrill", "1");
      }

      if (this.a.getEnableDataValueEditing()) {
         var1.a("editData", "1");
      }

   }
}
